class PublicUser {
    constructor() {
    }
    $(e){return document.querySelector(e)}
    ges(el){return document.querySelectorAll(el)}
    get({
        url,
        text = {},
        callback
    }) {
        let xhr = new XMLHttpRequest;
        let abb = url + "?" + trun(text)
        xhr.open("get", abb)
        xhr.send()
        xhr.onreadystatechange = () => {
            if (xhr.readyState === 4) {
                callback(xhr.responseText)
            }
        }
        function trun(obj) {
            let arr = new Array()
            for (let key in obj) {
                arr.push(`${key}=${obj[key]}`)
            }
            return arr.join("&")
        }
    }
    post({
        url,
        text = {},
        hed = {},
        callback
    }) {
        let xhr = new XMLHttpRequest;
        xhr.open("POST", url)
        Object.keys(hed).forEach(item => {
            xhr.setRequestHeader(item, hed[item])
        })
        xhr.send(JSON.stringify(text))
        xhr.onreadystatechange = () => {
            if (xhr.readyState === 4) {
                callback(xhr.responseText)
            }
        }
    }
}